package com.iweb.newa202104.controller;

import com.iweb.newa202104.dto.ResourceInputDTO;
import com.iweb.newa202104.enums.Err;
import com.iweb.newa202104.exception.CommonException;
import com.iweb.newa202104.service.ResourceService;
import com.iweb.newa202104.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * description:  <br>
 * date: 2021/5/12 20:41 <br>
 * author: ztz <br>
 * version: 1.0 <br>
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/resource")
public class ResourceController {
    @Autowired
    ResourceService resourceService;
    @GetMapping("/getResourceByCategory")
    public ResultVO getResourceByCategory(String categoryId){
        try {
            return resourceService.getResourceByCategory(Integer.parseInt(categoryId));
        } catch (NumberFormatException e) {
            throw new CommonException(Err.PRAM_ERR);
        }
    }


}
